package middleware

import (
	"goserver/utils"
	"net/http"
)

// 中间件：检查请求方法和内容类型
func CheckRequestMiddleware(next http.HandlerFunc) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		// 检查请求方法
		if r.Method != http.MethodPost && r.Method != http.MethodGet {
			utils.Response(w, 201, "服务端错误: 只接受POST或GET请求", nil)
			return
		}

		next(w, r)
	}
}
